package com.kingyea.mobilepolice.apimanage.providerservicemonitor.controller;

import com.kingyea.mobilepolice.apimanage.log.OperateType;
import com.kingyea.mobilepolice.apimanage.log.OperationLogAnnotation;
import com.kingyea.mobilepolice.apimanage.providerservicemonitor.bean.ProviderServiceMonitor;
import com.kingyea.mobilepolice.apimanage.providerservicemonitor.service.ProviderServiceMonitorService;
import com.kingyea.mobilepolice.apimanage.serviceinfo.bean.ServiceInfo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author Mr.Lin
 * @version v1.0.0
 * @description ProviderServiceMonitor 控制层
 * @date Created in 2018-05-21 14:11:27
 */
@RequestMapping(value = "/providerServiceMonitor")
@RestController
public class ProviderServiceMonitorController {

    private static final Logger LOGGER = LoggerFactory.getLogger(ProviderServiceMonitorController.class);

    @Autowired
    private ProviderServiceMonitorService providerServiceMonitorService;

    /**
     * 查询全部
     *
     * @param
     * @return
     */
    @RequestMapping(method = RequestMethod.GET)
    public Object list() throws Exception {
        return providerServiceMonitorService.list(null);
    }

    /**
     * 通过ID查找对象
     *
     * @param hostSerialNo
     * @param timeId
     * @return
     */
    @RequestMapping(value = "/{hostSerialNo}/{timeId}", method = RequestMethod.GET)
    public Object detail(@PathVariable String hostSerialNo, @PathVariable Long timeId) throws Exception {
        return providerServiceMonitorService.getById(hostSerialNo, timeId);
    }

    /**
     * 创建
     *
     * @param providerServiceMonitor
     * @return
     */
    @RequestMapping(method = RequestMethod.POST)
    public Object create(@RequestBody ProviderServiceMonitor providerServiceMonitor) throws Exception {
        return providerServiceMonitorService.save(providerServiceMonitor);
    }

    /**
     * 更新
     *
     * @param providerServiceMonitor
     * @return
     */
    @RequestMapping(method = RequestMethod.PUT)
    public Object update(@RequestBody ProviderServiceMonitor providerServiceMonitor) throws Exception {
        return providerServiceMonitorService.update(providerServiceMonitor);
    }

    /**
     * 删除
     *
     * @param hostSerialNo
     * @param timeId
     * @return
     */
    @RequestMapping(value = "/{hostSerialNo}/{timeId}", method = RequestMethod.DELETE)
    public Object delete(@PathVariable String hostSerialNo, @PathVariable Long timeId) throws Exception {
        return providerServiceMonitorService.deleteById(hostSerialNo, timeId);
    }


    /**
     * 性能数据上报
     *
     * @param
     * @return java.lang.Object
     * @author Mr.Lin
     * @date 2018/5/21 14:21
     */
    @RequestMapping(value = "/{hostSerialNo}", method = RequestMethod.POST)
    public Object report(@RequestBody ProviderServiceMonitor providerServiceMonitor) throws Exception {
        return providerServiceMonitorService.report(providerServiceMonitor);
    }

    /**
     * 根据搜索条件搜索性能数据列表
     *
     * @param map
     * @return com.device.mall.utils.page.PageInfo
     * @author Mr.Lin
     * @date 2017/11/20 15:57
     */
    @ApiOperation(value = "根据搜索条件搜索接口列表", notes = "", response = ServiceInfo.class)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageNum", value = "第几页", required = true, dataType = "int")
            , @ApiImplicitParam(name = "pageSize", value = "每页数据数量大小", required = true, dataType = "int")
//            , @ApiImplicitParam(name = "serviceName", value = " 服务名称 ", required = true, dataType = "String")
//            , @ApiImplicitParam(name = "serviceSerialNo", value = " 服务标识 ", required = true, dataType = "String")
//            , @ApiImplicitParam(name = "providerName", value = " 服务方名字 ", required = true, dataType = "String")
            , @ApiImplicitParam(name = "providerSerialNo", value = " 服务方标识 ", required = true, dataType = "String")
            , @ApiImplicitParam(name = "startTime", value = "开始时间", required = true, dataType = "Date")
            , @ApiImplicitParam(name = "endTime", value = "结束时间", required = true, dataType = "Date")
    })
    @OperationLogAnnotation(operateName = "根据搜索条件搜索性能数据列表", operateType = OperateType.SELECT, module = "providerservicemonitor")
    @RequestMapping(value = "/searchByCondition", method = RequestMethod.POST)
    public Object searchByCondition(@RequestBody Map<String, Object> map) throws Exception {
        return providerServiceMonitorService.searchByCondition(map);
    }

}
